package fr.utbm.gi.in56.ads;

import java.io.Serializable;
import java.util.Date;

/**
 * Implementation of an ad.
 *
 * @author Adrien Hoffer & Tarik Belabbas
 *
 */
public abstract class Ad implements Serializable
{
	/**
	 * Version number associated to the serializable class.
	 */
	private static final long	serialVersionUID	= -5324636482996259665L;

	/**
	 * The id of the ad
	 */
	private int 		id;
	
	/**
	 * the login of the seller
	 */
	private String		loginSeller;
	
	/**
	 * The login of the buyer 
	 */
	private String		loginBuyer;
	
	/**
	 * The title of the ad 
	 */
	private String 		title;
	
	/**
	 * The type of gearbox
	 */
	private int		 	isAutomatic;
	
	/**
	 * The description of the ad
	 */
	private String 		description;
	
	/**
	 * The state of the ad
	 */
	private AdState 	adState;
	
	/**
	 * The date of the ad
	 */
	private Date 		adDate;
	
	/**
	 * The id of the energy type used by the vehicle
	 */
	private int 		idEnergy;
	
	/**
	 * The energy of the car
	 */
	private String 		energy;
	
	/**
	 * The id of the model of the vehicle
	 */
	private int 		idModel;
	
	/**
	 * The model of the car
	 */
	private String 		model;
	
	/**
	 * The id of the brand of the car
	 */
	private int 		idBrand;
	
	/**
	 * The brand of the car
	 */
	private String 		brand;
	
	/**
	 * The control state of the ad
	 */
	private boolean 	isChecked = false;
	
	
	/**
	 * The global rate of the poster
	 */
	private int 		userRate;
	
	/**
	 * The county of the poster
	 */
	private int 		userCounty;
	
	/**
	 * Default constructor
	 */
	public Ad()
	{
		this.id 			= 0;
		this.adDate 		= null;
		this.adState 		= AdState.OPENED;
		this.title 			= ""; //$NON-NLS-1$
		this.idBrand 		= 0;
		this.brand 			= ""; //$NON-NLS-1$
		this.idModel		= 0;
		this.model			= ""; //$NON-NLS-1$
		this.description 	= ""; //$NON-NLS-1$
		this.idEnergy		= 0;
		this.energy			= ""; //$NON-NLS-1$
		this.isAutomatic	= -1;
		this.isChecked		= false;
		this.loginBuyer		= ""; //$NON-NLS-1$
		this.loginSeller	= ""; //$NON-NLS-1$
		this.userCounty		= 0;
		this.userRate		= -1;
	}
	
	/**
	 * Parameterized constructor 
	 */
	public Ad(int _id, Date _adDate, int _adState, String _title, int _idBrand,
			String _brand, int _idModel, String _model, String _description, int _idEnergy,
			String _energy, int _isAutomatic, boolean _isChecked, String _loginBuyer,
			String _loginSeller, int _userCounty, int _userRate)
	{
		this.id 			= _id;
		this.adDate 		= _adDate;
		this.adState 		= AdState.values()[ _adState ];
		this.title 			= _title;
		this.idBrand 		= _idBrand;
		this.brand 			= _brand;
		this.idModel		= _idModel;
		this.model			= _model;
		this.description 	= _description;
		this.idEnergy		= _idEnergy;
		this.energy			= _energy;
		this.isAutomatic	= _isAutomatic;
		this.isChecked		= _isChecked;
		this.loginBuyer		= _loginBuyer;
		this.loginSeller	= _loginSeller;
		this.userCounty		= _userCounty;
		this.userRate		= _userRate;
	}
	
	/**
	 * Returns the energy
	 *
	 * @return the energy
	 */
	public String getEnergy()
	{
		return this.energy;
	}

	/**
	 * Sets the energy
	 *
	 * @param energy the energy to set
	 */
	public void setEnergy( String energy )
	{
		this.energy = energy;
	}

	/**
	 * Returns the id of the model
	 *
	 * @return the idModel
	 */
	public int getIdModel()
	{
		return this.idModel;
	}

	/**
	 * Sets the id of the model
	 *
	 * @param idModel the idModel to set
	 */
	public void setIdModel( int idModel )
	{
		this.idModel = idModel;
	}

	/**
	 * Returns the id of the brand
	 *
	 * @return the idBrand
	 */
	public int getIdBrand()
	{
		return this.idBrand;
	}

	/**
	 * Sets the id of the brand
	 *
	 * @param idBrand the idBrand to set
	 */
	public void setIdBrand( int idBrand )
	{
		this.idBrand = idBrand;
	}

	/**
	 * Returns the brand
	 *
	 * @return the brand
	 */
	public String getBrand()
	{
		return this.brand;
	}

	/**
	 * Sets the brand
	 *
	 * @param brand the brand to set
	 */
	public void setBrand( String brand )
	{
		this.brand = brand;
	}

	/**
	 * Returns the user global rate
	 *
	 * @return the userRate
	 */
	public int getUserRate()
	{
		return this.userRate;
	}

	/**
	 * Sets the user global rate
	 *
	 * @param userRate the userRate to set
	 */
	public void setUserRate( int userRate )
	{
		this.userRate = userRate;
	}

	/**
	 * Returns the user county
	 *
	 * @return the userCounty
	 */
	public int getUserCounty()
	{
		return this.userCounty;
	}

	/**
	 * Sets the user county
	 *
	 * @param userCounty the userCounty to set
	 */
	public void setUserCounty( int userCounty )
	{
		this.userCounty = userCounty;
	}

	/**
	 * Sets the model of the car
	 *
	 * @param model the model to set
	 */
	public void setModel( String model )
	{
		this.model = model;
	}
	
	/**
	 * Returns the model
	 * 
	 * @return the model
	 */
	public String getModel()
	{
		return this.model;
	}

	/**
	 * Returns the id of the ad
	 *
	 * @return the id
	 */
	public int getId()
	{
		return this.id;
	}

	/**
	 * Set the id of the ad
	 *
	 * @param id the id to set
	 */
	public void setId( int id )
	{
		this.id = id;
	}

	/**
	 * Returns the login of the seller
	 *
	 * @return the loginSeller
	 */
	public String getLoginSeller()
	{
		return this.loginSeller;
	}

	/**
	 * Set the login of the seller
	 *
	 * @param loginSeller the loginSeller to set
	 */
	public void setLoginSeller( String loginSeller )
	{
		this.loginSeller = loginSeller;
	}

	/**
	 * Returns the login of the buyer
	 *
	 * @return the login of the buyer
	 */
	public String getLoginBuyer()
	{
		return this.loginBuyer;
	}

	/**
	 * Set the login of the buyer
	 *
	 * @param loginBuyer the loginBuyer to set
	 */
	public void setLoginBuyer( String loginBuyer )
	{
		this.loginBuyer = loginBuyer;
	}

	/**
	 * Returns the title of the ad
	 *
	 * @return the title
	 */
	public String getTitle()
	{
		return this.title;
	}

	/**
	 * Sets the title of the ad
	 *
	 * @param title the title to set
	 */
	public void setTitle( String title )
	{
		this.title = title;
	}

	/**
	 * Returns the isAutomatic value
	 *
	 * @return the isAutomatic value
	 */
	public int isAutomatic()
	{
		return this.isAutomatic;
	}

	/**
	 * Sets if the gearbox is automatic or not
	 *
	 * @param isAutomatic the isAutomatic to set
	 */
	public void setAutomatic( int isAutomatic )
	{
		this.isAutomatic = isAutomatic;
	}

	/**
	 * Returns the description of the ad
	 *
	 * @return the description
	 */
	public String getDescription()
	{
		return this.description;
	}

	/**
	 * Set the description of the ad
	 * 
	 * @param description the description to set
	 */
	public void setDescription( String description )
	{
		this.description = description;
	}

	/**
	 * Returns the state of the ad
	 *
	 * @return the adState
	 */
	public AdState getAdState()
	{
		return this.adState;
	}

	/**
	 * Set the state of the ad
	 *
	 * @param adState the adState to set
	 */
	public void setAdState( AdState adState )
	{
		this.adState = adState;
	}

	/**
	 * Returns the date when the ad was posted
	 *
	 * @return the adDate
	 */
	public Date getAdDate()
	{
		return this.adDate;
	}

	/**
	 * Sets the date when the ad was posted
	 *
	 * @param adDate the adDate to set
	 */
	public void setAdDate( Date adDate )
	{
		this.adDate = adDate;
	}

	/**
	 * Returns the id of the energy used by the vehicle
	 *
	 * @return the id of the energy used by the vehicle
	 */
	public int getIdEnergy()
	{
		return this.idEnergy;
	}

	/**
	 * Set the id of the energy used by the vehicle
	 *
	 * @param idEnergy the idEnergy to set
	 */
	public void setIdEnergy( int idEnergy )
	{
		this.idEnergy = idEnergy;
	}

	/**
	 * Returns <tt>true</tt> if the ad is already checked by an admin
	 *
	 * @return the isChecked
	 */
	public boolean isChecked()
	{
		return this.isChecked;
	}

	/**
	 * Sets if the ad is already checked by an admin
	 *
	 * @param isChecked the isChecked to set
	 */
	public void setChecked( boolean isChecked )
	{
		this.isChecked = isChecked;
	}
	
	
}
